<?php
  require_once('db.php');

  if(isset($_POST['email']) && !empty($_POST['email'])) {

    unset($_POST['cpassword']);
    unset($_POST['submitUsers']);
    pr($_POST);
    $q = '';
    foreach($_POST as $colName=>$colValue) {
      pr("`$colName`='$colValue', ");
      $q .= "`$colName`='$colValue', ";

    }
    pr(" `added_date`=NOW(),`status`='1'");
    $q .= " `added_date`=NOW(),`status`='1'";

    $insertQuery = " INSERT INTO `sanjay` SET  $q";
    pr($insertQuery);
    mysql_query($insertQuery) or die(mysql_error());
    if(mysql_affected_rows() > 0) {
      echo "<h2>USer Inserted successfully</h2>";
    }
  }

?>

<form name="users" method="post" action="">
  <table border="1" width="80%" align="center">
    <thead>
      <tr><th colspan="2">Please fill the details</th></tr>
    </thead>

    <tbody>
      <tr>
        <td>Name :</td>
        <td><input type="text" required name="uname"></td>
      </tr>

      <tr>
        <td>Email :</td>
        <td><input type="email" required name="email"></td>
      </tr>

      <tr>
        <td>Password :</td>
        <td><input type="password" autocomplete="off" required name="password"></td>
      </tr>

      <tr>
        <td>Confirm Password :</td>
        <td><input type="password" required name="cpassword"></td>
      </tr>

      <tr>
        <td>&nbsp;</td>
        <td><input type="submit" name="submitUsers" value="I am done!!"></td>
      </tr>

    </tbody>
  </table>
</form>


